import React, { memo } from "react";
import { View, Text } from "@tarojs/components";
import Taro from '@tarojs/taro';
import { Cell, Empty } from '@antmjs/vantui'
import { formatDate } from "@/utils/fomatter";


import './index.scss'

const ObsPoolComp = (props) => {
  const { poolItem = {} } = props
  const goReportDetail = (item) => {
    Taro.navigateTo({
      url: '/obsPoolDetail/reportDetail/index?data=' + `${encodeURIComponent(JSON.stringify(item))}`
    })
  }
  return (
    <View className='pool-card'>
      {
        poolItem.reportList && poolItem.reportList.length >= 3 ?
          <Cell
            border={false}
            title={poolItem.poolName}
            value='全部'
            isLink
            linkType='navigateTo'
            url={'/obsPoolDetail/obsPoolList/index?data=' + `${encodeURIComponent(JSON.stringify(poolItem))}`}
          />
          :
          <View className='pool-title'>
            {poolItem.poolName}
          </View>

      }
      <View className='pool-list'>
        {
          poolItem.reportList?.length ?
            poolItem.reportList.slice(0, 3).map((item, index) => {
              return (
                <View
                  key={item.poolId}
                  className='pool-item'
                  style={{ borderBottom: index == poolItem.reportList.length - 1 ? 'none' : '' }}
                  onClick={() => goReportDetail(item)}
                >
                  <View className='item-title text3'>{formatDate(item.netDate?.toString(), 'string', 'YYYY年MM月')} | {item.reportName}</View>
                  <View className='item-date'>净值日期 {formatDate(item.netDate?.toString(), 'string', 'MM-DD')}</View>
                </View>
              )
            })
            :
            <Empty
              image='https://static.hzddyy.com/taiyi/tt/public_placeholder_nodata.png'
              description='暂无数据'
            />

        }

      </View>

    </View>
  );
};

export default memo(ObsPoolComp);
